<?php
/**
 * Created by PhpStorm.
 * User: ship
 * Date: 2024/12/26
 * Time: 18:33
 */

namespace ShipSun\LaravelRequestResponseJm;

use Illuminate\Support\ServiceProvider;

/**
 * Class LaravelRequestResponseJmProvider
 * @package ShipSun\LaravelRequestResponseJm
 */
class LaravelRequestResponseJmProvider extends ServiceProvider
{
    public function register()
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/jm.php', 'jm');
        $config = config('jm', []);
        $enable = $config['enable'] ?? true;
        $jm_key = $config['jm_key'] ?? '123456';
        BaseMiddleware::$enable = $enable;
        BaseMiddleware::$jm_key = $jm_key;
        BaseMiddleware::$close_path = $config['close_path'] ?? [];

        RequestDecryptMiddleware::$request_method = $config['request_method'] ?? [];

        ResponseEncryptMiddleware::$response_method = $config['response_method'] ?? [];

        $this->publishes([__DIR__ . '/../config/jm.php' => $this->app->configPath('jm.php')], ['request_response_jm']);
    }
}